<?php
   error_reporting(0);
   define('__ROOT__', dirname(dirname(__FILE__)));
   require_once(__ROOT__.'\config\config.php'); 
   require_once (__ROOT__.'\model\db.php');
   require_once (__ROOT__.'\model\products.php');
   $product = new Products();
   $products = $product->selectid($_GET['id']);
   if(!isset($_GET['id']))
   {
       print'location.href = "'.HOST.'index.php";';
   }
?>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Product Details | E-Shopper</title>
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/font-awesome.min.css" rel="stylesheet">
    <link href="../css/prettyPhoto.css" rel="stylesheet">
    <link href="../css/price-range.css" rel="stylesheet">
    <link href="../css/animate.css" rel="stylesheet">
	<link href="../css/main.css" rel="stylesheet">
	<link href="../css/responsive.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->       
    <link rel="shortcut icon" href="images/ico/favicon.ico">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="images/ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="images/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="images/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="images/ico/apple-touch-icon-57-precomposed.png">
</head><!--/head-->

<body>
	<header id="header"><!--header-->
            <?php
                if(empty($_SESSION))
                    session_start ();
                if(isset($_SESSION['email']))   
                    require_once (__ROOT__.'/view/header_login_succeed.php');
                else{
                    require_once (__ROOT__.'/view/header_login.php');
                }
            ?>
	</header><!--/header-->
        <?php
            if(!empty($_GET["action"])){
                require (__ROOT__.'/controller/addcart.php');
                print'<script type="text/javascript">';
                print'location.href = "./view_product-detail.php?id='.$_GET['id'].'";';
                print'</script>';
            }    
        ?>
	<section>
		<div class="container">
			<div class="row">
                            <?php require_once (__ROOT__.'/view/index_view_category.php'); ?>
                            <?php foreach($products as $productss) : ?>
				<div class="col-sm-9 padding-right">
					<div class="product-details"><!--product-details-->
						<div class="col-sm-5">
							<div class="view-product">
                                                            <img src="<?php echo HOST ?>/images/product/<?php echo $productss['image'] ?>" alt="" />
							</div>
							<div id="similar-product" class="carousel slide" data-ride="carousel">
								
								  <!-- Wrapper for slides -->
								

								  <!-- Controls -->
								  <a class="left item-control" href="#similar-product" data-slide="prev">
									<i class="fa fa-angle-left"></i>
								  </a>
								  <a class="right item-control" href="#similar-product" data-slide="next">
									<i class="fa fa-angle-right"></i>
								  </a>
							</div>

						</div>
						<div class="col-sm-7">
							<div class="product-information"><!--/product-information-->
								<h2><?php echo $productss['name'] ?></h2>
								<p>MÃ SẢN PHẨM: <?php echo $productss['id'] ?></p>
                                                                <img src="../images/product-details/rating.png" alt="" />
								<span>
									<span><?php echo number_format($productss['price'] , 0, ',', '.') ?></span>
									<label>Quantity:</label>
									<input type="text" value="<?php echo $productss['quantity'] ?>" />
									<button type="button" class="btn btn-fefault cart" onclick="window.location.href = '<?php echo HOST ?>view/view_product-detail.php?id=<?php echo $_GET['id'] ?>&action=add&quantity=1&name=<?php echo $productss['name'] ?>';">
										<i class="fa fa-shopping-cart"></i>
										Add to cart
									</button>
								</span>
                                                                <p><b>Tình Trạng:</b> <?php if($productss['quantity'] > 0) echo 'Còn Hàng'; else echo 'Hết Hàng'; ?></p>
								<p><b>Ngày Nhập</b> <?php echo $productss['date'] ?></p>
								<p><b>Thương Hiệu:</b> H-SHOPPER</p>
                                                                <a href=""><img src="../images/product-details/share.png" class="share img-responsive"  alt="" /></a>
							</div><!--/product-information-->
						</div>
					</div><!--/product-details-->		
				</div>
                           <?php endforeach; ?>
			</div>
		</div>
	</section>
	<?php  require_once (__ROOT__.'\view\footer.php'); ?>
	
	

  
    <script src="../js/jquery.js"></script>
	<script src="../js/price-range.js"></script>
    <script src="../js/jquery.scrollUp.min.js"></script>
	<script src="../js/bootstrap.min.js"></script>
    <script src="../js/jquery.prettyPhoto.js"></script>
    <script src="../js/main.js"></script>
</body>
</html>